#ifndef AICHATDIALOG_H
#define AICHATDIALOG_H

#include"global.h"
#include "widget/aidialogboxwid.h"
#include <QDialog>

namespace Ui {
class AIChatDialog;
}

class AIChatDialog : public QDialog
{
    Q_OBJECT

public:
    explicit AIChatDialog(QWidget *parent = nullptr);
    ~AIChatDialog();

private:
    void addChatFrame(const QString &sender, const QString &text, const UserType &type, const NewsType &nt, bool b);
    void processStreamData(const QByteArray&);
    QByteArray jsonCreate();

protected:
    void keyPressEvent(QKeyEvent *event) override;

private slots:
    void on_pushButton_clicked();
    void slot_stream_output();

private:
    Ui::AIChatDialog *ui;
    int textIndex{0};
    QString textChunks{""};
    QNetworkAccessManager *xunfei{nullptr};
    QNetworkRequest xunfeinet;
    QTimer* timer;
    QString nowText{""};
    bool isFinish{true};
    bool isRequestFinish{true};
    AIDialogBoxWid *dialogBox;
};

#endif // AICHATDIALOG_H
